import { BrowserRouter, Routes, Route } from 'react-router-dom'
import routes, { IRoute } from './routes'

const Router: React.FC = () => {

	const routerView = (routes: IRoute[]) => {
		return routes.map((v, i) => {
			return <Route key={i} path={v.path} element={<v.element></v.element>}>
				{v.children && routerView(v.children)}
			</Route>
		})
	}


	return (
		<BrowserRouter>
			<Routes>
				{
					routerView(routes)
				}
			</Routes>
		</BrowserRouter>
	)
}


export default Router